<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"    
      xmlns:p="http://primefaces.org/ui">
    <ui:composition template="../TemplateAdmin.xhtml">
        <ui:define name="title">
            <h:outputText value="Statistic Project"></h:outputText>
        </ui:define>       
        <ui:define name="body">        
            <h:form id="form" style="width: 100%">
                <p:growl id="messages" showDetail="true"/> 
                <h:outputText value="Search By:"/>
                <h:selectOneMenu value="#{projectController.dateType}">
                    <f:selectItem itemLabel="Date Created" itemValue="0"/>
                    <f:selectItem itemLabel="Date Adjustmented" itemValue="1"/>
                    <p:ajax event="change" update="dataTable" listener="#{projectController.prepareItemsStt()}"/>
                </h:selectOneMenu>
                <h:outputLabel value="StartDate:" />
                <p:calendar pattern="MM/dd/yyyy" navigator="true" value="#{projectController.dateStart}" title="date start">
                    <f:convertDateTime pattern="MM/dd/yyyy" />
                    <p:ajax event="dateSelect" update="dataTable" listener="#{projectController.prepareItemsStt()}"/>
                </p:calendar>
                <h:outputLabel value="EndDate" />
                <p:calendar pattern="MM/dd/yyyy" navigator="true" value="#{projectController.dateEnd}" title="date end" >
                    <f:convertDateTime pattern="MM/dd/yyyy" />
                    <p:ajax event="dateSelect" update="dataTable" listener="#{projectController.prepareItemsStt()}"/>
                </p:calendar>

                <p:dataTable id="dataTable" var="item" value="#{projectController.itemsStt}" resizableColumns="true"
                             
                             paginator="true" rows="10" paginatorPosition="bottom"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                             rowsPerPageTemplate="5,10,15" style="width: 100%" widgetVar="roomTable">
                    <f:facet name="header">
                        <h:outputText value="List of Complaint"/>
                        <p:outputPanel style="float: right">
                            <h:outputText value="Search by all fileds"/>
                            <h:inputText id="globalFilter" onkeyup="roomTable.filter();"/>
                        </p:outputPanel>
                    </f:facet>                

                    <p:column headerText="ID" sortBy="#{item.prID}" filterMatchMode="exact" filterBy="#{item.prID}">
                        <h:outputText value="#{item.prID}" style="width: 100%"/>                   
                    </p:column>
                    <p:column headerText="Order" sortBy="#{item.odID}" filterMatchMode="exact" filterBy="#{item.odID}">                    
                        <p:commandButton value="View Order" action="#{orderController.sttView(item.odID)}"/>
                    </p:column>
                    <p:column headerText="Manager" sortBy="#{item.mnID.mnName}" filterMatchMode="contains" filterBy="#{item.mnID.mnName}">
                        <h:outputText value="#{item.mnID.mnName}" style="width: 100%"/>                  
                    </p:column>      
                    <p:column sortBy="#{item.prCreated}" headerText="Created Date">
                        <h:outputText value="#{item.prCreated}">
                            <f:convertDateTime pattern="MM/dd/yyyy" />
                        </h:outputText>
                    </p:column>

                    <p:column sortBy="#{item.prCompleted}" headerText="Adjustmented Date">                      
                        <h:outputText value="#{item.prCompleted}">
                            <f:convertDateTime pattern="MM/dd/yyyy" />
                        </h:outputText>
                    </p:column>
                    <p:column headerText="Status" sortBy="#{item.prState}"
                              filterBy="#{item.prState}" filterMatchMode="contains" filterOptions="#{projectController.itemState}" filterValue="">
                        <h:outputText value="Chua bat dau" rendered="#{item.prState == 1}"/>
                        <h:outputText value="Dang duoc thuc hien" rendered="#{item.prState == 2}"/>
                        <h:outputText value="Dang can bao tri" rendered="#{item.prState == 3}"/>              
                        <h:outputText value="Dang duoc bao tri" rendered="#{item.prState == 4}"/>  
                        <h:outputText value="Da hoan thien" rendered="#{item.prState == 5}"/>  
                    </p:column>
                    <p:column headerText="Status" sortBy="#{item.prEnable}"
                              filterBy="#{item.prEnable}" filterMatchMode="contains">
                        <h:outputText value="#{item.prEnable}"/>                 
                    </p:column>   
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value=""/>
                        </f:facet>
                        <p:commandButton action="#{projectController.sttView(item)}"   icon="ui-icon-extlink"                                             
                                         title="Detail" value="Detail"  >
                        </p:commandButton>                       
                    </p:column>
                </p:dataTable>

            </h:form>
        </ui:define>
    </ui:composition>
</html>
